var log = function(content) {
	console.log(content);
}

var adapt = (function() {
	return {
		openPage : function(selector, data) {
			location.hash = selector;
			if (data) {
				$(selector).data(data.key, data.value);
			}
		}
	};
})(window);
$(window).on('hashchange', function() {
	var beforeOpen = "beforeOpen";
	var afterOpen = "afterOpen";
	var beforeClose = "beforeClose";
	var afterClose = "afterClose";
	var selector = location.hash;
	$(".page.active").each(function(i, e) {
		var $e = $(e);
		$e.trigger(beforeClose);
		$e.removeClass("active");
		$e.trigger(afterClose);
	});
	$(selector).trigger(beforeOpen);
	$(selector).addClass("active");
	$(selector).trigger(afterOpen);
});
$(function () {
	location.hash="#";
});